<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>{:$page_info['title']}</title>
<link rel="icon" href="favicon.ico" type="image/ico">

<meta name="author" content="yinqi">
<link href="__STATIC__/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/style.min.css" rel="stylesheet">

<link href="__STATIC__/common/select2/select2.css" rel="stylesheet">
<link href="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">

<link href="__STATIC__/admin/css/cch.css" rel="stylesheet">
</head>
<style type="text/css">
    .table td {white-space: pre-wrap!important;word-break: break-all;}
</style>
<body>
<div class="container-fluid p-t-15">
  
  <div class="row" id="cont">
    <div class="col-lg-12">
      <div class="card">
        
        
        <div class="card-body">
          
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <tr>
                        <th>授权码</th>
                        <td>{:$data['authorization_sn']}</td>
                    </tr>
                    <tr>
                        <th>标题</th>
                        <td>{:$data['title']}</td>
                    </tr>
                    <tr>
                        <th>账号</th>
                        <td>{:$data['account']}</td>
                    </tr>
                    <tr>
                        <th>UID</th>
                        <td>{:$data['uid']}</td>
                    </tr>
                    <tr>
                        <th>详细说明</th>
                        <td>{:$data['content']}</td>
                    </tr>
                    <tr>
                        <th>创建时间</th>
                        <td>{:timeDef($data['ctime'],'','Y-m-d H:i:s')}</td>
                    </tr>
                </table>
            </div>

        </div>
        <?php if ($data['status'] == 0): ?>
            <header class="card-header">
                <div class="card-title">授权签名</div>
            </header>
            <div class="card-body">
                <div id="writers">
                    <!-- <div id="someelement" ><img src="" id="images"></div> -->
                    <div id='signature' style='background-color: #d2d2e8;'></div>
                </div>
              
            </div>
        <?php endif ?>
      </div>


    </div>
    
  </div>
    <?php if ($data['status'] == 0): ?>
    <div class="card">
        <div class="card-body">
            <div class="form-group col-md-12">
              <button type="button" class="btn btn-primary ajax-post" id="yes">确 定</button>
              <button type="button" class="btn btn-default" id="reset">重 写</button>
            </div>
        </div>
    </div>
    <?php endif ?>
  
</div>

<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>

<!-- 时间选择器 -->
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/moment.min.js"></script>
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/locale/zh-cn.js"></script>

<script src="__STATIC__/common/select2/select2.min.js"></script><!-- 下拉搜索 -->

<script type="text/javascript" src="__STATIC__/admin/js/lyear-loading.js"></script><!-- loading -->

<script src="__STATIC__/common/jSignature/jSignature.js"></script><!-- 下拉搜索 -->
<script type="text/javascript" src="__STATIC__/admin/js/cch.js"></script>
</body>
<script type="text/javascript">
    $(function(){
        $("#signature").jSignature();
    });

    //重置画布，清楚笔记
    $("#reset").click(function(){
        $("#signature").jSignature("reset"); //重置画布，可以进行重新作画
        $("#images").attr('src','');
    });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script>
    $("#yes").click(function(){
        html2canvas($('#cont'), {
            onrendered: function (canvas) {
            var img = canvas.toDataURL("image/png",1.0);
            $.ajax({
                type: 'POST',
                url: "{:url('upload')}",
                data:{
                  "img":img,
                  'authorization_sn':'{:$data['authorization_sn']}'
                },
                success:function(data){
                    if (data.status == 1) {
                        window.location.href = data.url;
                    }else{
                        alert(data.msg);
                    }
                }
            });
          }
        });
    });
</script> 
</html>